using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace ShowSystem
{
    public class ShowSystem : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        /* Define components */
        AllComponent allComponent;
        
        /* for test */
        SpriteBatch spriteBatch;
        SpriteFont spriteFont;
        MultiFrame2D sprite;
        Texture2D tex;

        /* for test */

        public ShowSystem()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            /* Add components */
            allComponent = new AllComponent(this);
            Components.Add(allComponent);

            base.Initialize();
        }

        protected override void LoadContent()
        {
            /* for test */
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>(@"font\English12");
            tex = Content.Load<Texture2D>(@"test\sprites");
            sprite = new MultiFrame2D(tex, new Point(60, 60), new Point(6, 8), 60);
            sprite.Initialize(new Vector2(0,0), Vector2.Zero, 1.0f, 0);

            sprite.Word = "Hello World!";
            sprite.WordPosition = new Vector2(sprite.Position.X + sprite.FrameSize.X, sprite.Position.Y);
            sprite.WordColor = Color.Red;
            /* for test */

        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();
            /* for test */
            sprite.Update(gameTime);
            /* for test */


            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            /* for test */
            spriteBatch.Begin();
            sprite.Draw(spriteBatch, spriteFont);


            spriteBatch.End();
            /* for test */


            base.Draw(gameTime);
        }
    }
}
